package com.ruoyi.manage.article.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.manage.article.domain.vo.CountVo;
import com.ruoyi.manage.article.mapper.AuthInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manage.article.mapper.ProjectMapper;
import com.ruoyi.manage.article.domain.Project;
import com.ruoyi.manage.article.service.IProjectService;

/**
 * projectService业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-21
 */
@Service
public class ProjectServiceImpl implements IProjectService 
{
    @Autowired
    private ProjectMapper projectMapper;

    @Autowired
    private AuthInfoMapper authInfoMapper;

    /**
     * 查询project
     * 
     * @param id project主键
     * @return project
     */
    @Override
    public Project selectProjectById(Long id)
    {
        return projectMapper.selectProjectById(id);
    }

    /**
     * 查询project列表
     * 
     * @param project project
     * @return project
     */
    @Override
    public List<Project> selectProjectList(Project project)
    {
        return projectMapper.selectProjectList(project);
    }

    /**
     * 新增project
     * 
     * @param project project
     * @return 结果
     */
    @Override
    public int insertProject(Project project)
    {
        project.setCreateTime(DateUtils.getNowDate());
        return projectMapper.insertProject(project);
    }

    /**
     * 修改project
     * 
     * @param project project
     * @return 结果
     */
    @Override
    public int updateProject(Project project)
    {
        project.setUpdateTime(DateUtils.getNowDate());
        return projectMapper.updateProject(project);
    }

    /**
     * 批量删除project
     * 
     * @param ids 需要删除的project主键
     * @return 结果
     */
    @Override
    public int deleteProjectByIds(Long[] ids)
    {
        return projectMapper.deleteProjectByIds(ids);
    }

    /**
     * 删除project信息
     * 
     * @param id project主键
     * @return 结果
     */
    @Override
    public int deleteProjectById(Long id)
    {
        return projectMapper.deleteProjectById(id);
    }

    @Override
    public AjaxResult count() {
        Integer certificationAudited = authInfoMapper.certificationAudited();
        Integer certificationNotAudited = authInfoMapper.certificationNotAudited();
        Integer projectReviewed = projectMapper.projectReviewed();
        Integer projectNotAudited = projectMapper.projectNotAudited();
        return AjaxResult.success(new CountVo(certificationAudited,
                certificationNotAudited, projectReviewed, projectNotAudited));
    }
}
